import 'package:honeypotflutter/net/public_http.dart';
import '../model/home_modulesModel.dart';

class HomeApi {
  /*
  *   请求菜单
  * */
  static Future<List<HomeModulesModel>> requestMenuList() async {
    try {
      var result = await MGHttp.get<List<dynamic>>("api/services/app/Mobile/GetMenu");
      if (result == null) {
        return [];
      }
      var modelList = result.map((e) => HomeModulesModel.fromJson(e)).toList();
      return modelList;
    } catch (error) {
      return Future.error(error);
    }
  }

  /*
  * 获取投递数据
  * */
  static Future<Map?> requestDeliver() async {
    try {
      var result = await MGHttp.get<Map>("api/services/app/BusinessPackage/GetCourierPackagesCount");
      return result;
    } catch (error) {
      return Future.error(error);
    }
  }

  /*
  * 获取投递数据
  * */
  static Future<Map?> requestReceive() async {
    try {
      var result = await MGHttp.get<Map>("api/services/app/SendPackage/GetCourierOrderCount");
      return result;
    } catch (error) {
      return Future.error(error);
    }
  }
}
